<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基础资料-总销量查询</title>
<link rel="shortcut icon" href="favicon.ico">
<!-- FontAwesome 4.3.0 -->
<link href="{$fonts.url}font-awesome-4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons 2.0.1 -->
<link href="{$fonts.url}ionicons-2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" />
<!--bootstrap-->
<link href="{$css.url}bootstrap_min.css" rel="stylesheet" type="text/css" />
<!--AdminLTE theme-->
<link href="{$css.url}AdminLTE_min.css" rel="stylesheet" type="text/css" />
<link href="{$css.url}AdminLT_skins/_all-skins.min.css" rel="stylesheet" type="text/css" />	
<!--datapicker-->
<link href="{$js.url}plugins/datapicker/datepicker.min.css" rel="stylesheet" type="text/css" />
<!--multiselect-->
<link href="{$js.url}plugins/multiselect/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css" />
<!--web css-->
<link rel="stylesheet" href="{$css.url}product_manage_min.css">	
<link rel="stylesheet" href="{$css.url}main.css">	
<!--[if lt IE 9]>
    <script src="{$js.url}plugins/html5shiv.min.js"></script>
    <script src="{$js.url}plugins/respond.min.js"></script>
<![endif]-->
{literal}
<style>
.box-body{min-height:350px;}
.table-toolbar .columns-right{position:relative;}
.table-toolbar .dropdown-menu{right:0;left:auto;max-height:340px;overflow:auto;}
.table-toolbar .dropdown-menu li{padding:5px 15px;}
.table-toolbar .dropdown-menu li p{margin:0;}
.img-thumbnail{width:50px;height:50px;}
.nav-tabs-custom{box-shadow:none;margin:10px 10px 0px 10px;}
</style>
{/literal}
</head>
<body class="skin-blue">
<div class="wrapper">
	{include file="bread_crumbs.php"}
	<!--引入面包屑-->
	<section class="base-setting-wrap">
		<div class="row">
			<div class="col-md-12">
				<div class="box">
					<div class="nav-tabs-custom">
						<ul class="nav nav-tabs">
					      <li><a href="/base/sale/index">子仓库销量查询</a></li>
					      <li class="active"><a href="/base/sale/sum">总仓库销量查询</a></li>					      
					    </ul>
				    </div>
	                <div class="box-header with-border clearfix">
	                	<div class="box-title pull-left">
	                		<a href="javascript:;" class="btn btn-primary btn-sm" id="illustration"><i class="fa fa-plus mr5"></i>销量说明查看</a>
	                	</div>
	                	<div class="box-form pull-right form-group-sm">
	                		<p class="pull-right">
	                			<a href="javascript:;" class="btn btn-success btn-sm" id="js_toggleSearchBox"><i class="fa fa-search"></i><span class="pl5">搜索选项</span></a>
	                		</p>
	                	</div>

	                	<div class="clearfix"></div>
						<div class="search-box" id="js_searchBox">
							<form method="get" action="" class="form-inline" id="cform">
								<div class="form-group-sm">
									<p class="no-margin">
										<label class="control-label">产品分类：</label>
										<select class="form-control" id="cat_id" deval='{$params.deval}'></select>
										<input type="hidden" name="product_type" id="select_cat_id"/>
										<label class="control-label ml10">搜索关键字类别：</label>
										<select class="form-control ml10" name="selected_product_type" id="selected_product_type">
											<option value="-">请选择</option>
			                				<option value="1"{if $params['selected_product_type'] == 1} selected{/if} selected>产品编码</option>
			                				<option value="2"{if $params['selected_product_type'] == 2} selected{/if}>产品名称</option>
		                				</select>
										<input type="text" class="form-control" name="searchbox">
										<button type="submit" class="btn btn-primary btn-sm" id="search_button">立即搜索</button>
										<a href="/base/sale/sum">清空搜索条件</a>
									</p>
								</div>
							</form>
						</div>
	                </div>
	                <!-- .box-header -->
	                <div class="box-body">
	                  <table class="table table-bordered table-striped table-hover">
	                  	<thead>
	                    <tr>
	                      <th>产品图片</th>
	                      <th width="95">产品编码</th>
	                      <th>产品名称</th>
	                      <th>产品分类</th>
	                      <th>可用库存</th>
	                      <th>前7天真实销量</th>
	                      <th>前15天真实销量</th>
	                      <th>前30天真实销量</th>
	                    </tr>
	                    </thead>
	                    {if isset($list)}
	                    	{foreach from=$list item="values"}
		                    <tr>	   
								<td><a href="{$values.thumb_url}" target="_blank"><img src="{$values.thumb_url}" class="img-thumbnail" width="50" height="50" data-toggle="tooltip" title="点击查看大图"></a></td>
								<td>{$values.goods_sn}</td>
								<td>{$values.product_name}</td>
								<td>{$values.cateName}</td>
								<td>{$values.sum_base_stock}</td>
								<td width="130">{$values.sum_real_sale_7}</td>
								<td width="130">{$values.sum_real_sale_15}</td>
								<td width="130">{$values.sum_real_sale_30}</td>
							</tr>
							{/foreach}
						{else}
							<tr>
								<td>没有找到数据···</td>
								<td colspan="12"></td>
							</tr>
	                    {/if}
	              	</table>
	                </div>
	                <!-- .box-body -->
	                <div class="box-footer text-center clearfix">{$page}</div>
	              </div>
			</div>
		</div>
	</section>
</div>

<script src="{$js.url}lib/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="{$js.url}lib/bootstrap.min.js" type="text/javascript"></script>
<script src="{$js.url}plugins/datapicker/bootstrap-datepicker-cn.js" type="text/javascript"></script>
<script src="{$js.url}plugins/multiselect/js/bootstrap-multiselect.js" type="text/javascript"></script>
<script src="{$js.url}plugins/layer.js" type="text/javascript"></script>
<script src="{$js.url}plugins/zeroclipboard/ZeroClipboard.min.js" type="text/javascript"></script>
<script src="{$js.url}linkagesel-min.js" type="text/javascript"></script>
<!--common js-->
<script src="{$js.url}common.js"></script>
<link rel="stylesheet" type="text/css" href="{$js.url}plugins/select2/css/select2.min.css">	
<script type="text/javascript" src="{$js.url}plugins/select2/js/select2.min.js"></script>	
<script>
var data = {$data};
{literal}
$('#illustration').click(function (){
	layer.alert(
		'<p><b>说明：</b>该模块查询产品在所有仓（排除虚拟仓、平台虚拟仓）的销量汇总数据 </p>',
 		{
			skin: 'layui-layer-lan',
			closeBtn: 1,
			shift: 5,
			title:"销量说明",
			area:["650px","auto"],
		}
	);
});
$('#dept_id option').each(function (){
	if($(this).val() == data['dept_id']){
		$(this).prop('selected', 'selected');
	}
});
$('#lifecycle option').each(function (){
	if($(this).val() == data['lifecycle']){
		$(this).attr('selected', 'selected');
	}
});
// $('#selected_product_type option').eq(data['selected_product_type']).prop('selected', 'selected');
$('input[name="searchbox"]').val(data['searchbox']);
function warehouse(){
	var did = $(this).find('option:selected').val();
	var str = '<option value="0">所有</option>';
	$.ajax({
		url : '/base/warehouse/getselectedwarehousebydeptid',
		data : {did : did},
		dataType : 'json',
		type : 'get',
		success : function (result){
			$.each(result, function(i, n){
				if(n.warehouse_code == data['warehouse_code']){
					str += '<option value="' + n.warehouse_code + '" selected>' + n.warehouse_name + '</option>';
				}else{
					str += '<option value="' + n.warehouse_code + '">' + n.warehouse_name + '</option>';
				}
			});
			$('select[name="warehouse_code"]').html(str);
		}
	});
	$("#warehouse_code").select2();
}
warehouse();
$('#dept_id').change(warehouse);
var strSplit = $("#cat_id").attr('deval').split(',');
var opts = {
	ajax: '/widget/category/getcat',
	selClass:'form-control inline',
	selStyle: 'font-size:12px;font-family:;microsoft YaHei;',
	autoLink : false,
	defVal: strSplit,
	head: '所有分类',
	select: '#cat_id'
};
var linkageSel = new LinkageSel(opts);
$('#search_button').click(function(){
	var v = linkageSel.getSelectedValue();
	$('#select_cat_id').val(v);
});
</script>
{/literal}
</body>
</html>
